package com.demo.fulllink.service.impl;

import com.demo.fulllink.module.po.OrderPO;
import com.demo.fulllink.module.vo.OrderVO;
import com.demo.fulllink.module.vo.ResponseVO;
import com.demo.fulllink.service.OrderDBService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;

@Slf4j
@RestController
@RequestMapping("/storage/order")
public class StorageOrderAPIController {
    
    @Autowired
    private OrderDBService orderDBService;
    
    @RequestMapping("/findByID/{orderid}")
    public OrderPO findByID(@PathVariable("orderid") Serializable orderid) {
        return orderDBService.findById(orderid);
    }
    
    @RequestMapping("/insert")
    public void insert(@RequestBody OrderPO orderPO) {
        log.info("storage 插入了订单");
        orderDBService.insert(orderPO);
    }
    
    @RequestMapping("/update")
    public void update(@RequestBody OrderPO orderPO) {
        orderDBService.updateById(orderPO);
    }
    
    @RequestMapping("/actualPlaceOrder")
    public ResponseVO actualPlaceOrder(@RequestBody OrderVO orderVO) {
        return orderDBService.actualPlaceOrder(orderVO);
    }
    
}
